package com.vision.bigDataApi.controller.oracle.slyz;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.vision.bigDataApi.enums.ReturnStatus;
import com.vision.bigDataApi.service.common.ResultService;
import com.vision.bigDataApi.service.oracle.slyz.SlyzService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/slyz")
public class SlyzController {

    @Value("${pageNum}")
    private int pageNum;

    @Value("${pageSize}")
    private int pageSize;

    @Autowired
    private ResultService resultService;
    @Autowired
    private SlyzService slyzService;

    /**
     * 水路运政管理信息系统_水路运输经营人信息   ENT_INFO表
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/getByEntInfo")
    @ResponseBody
    public String getByEntInfo(Integer pageNum,Integer pageSize)throws Exception{
        int pageN = 0;
        int pageS=0;
        if(pageNum!=null){
            pageN=pageNum;
        }
        else{
            pageN=this.pageNum;
        }
        if(pageSize!=null){
            pageS=pageSize;
        }
        else{
            pageS=this.pageSize;
        }
        PageHelper.startPage(pageN,pageS);
        List<Map<String, Object>> listMap = slyzService.getByEntInfo();
        PageInfo pageInfo=new PageInfo(listMap);
        long total = pageInfo.getTotal();//总共多少条
        return resultService.result(ReturnStatus.SUCCESS,listMap,"成功",total);

    }

    /**
     *水路运政管理信息系统 ENT_LICENSE     经营人许可信息
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/getByEntLicense")
    @ResponseBody
    public String getByEntLicense(Integer pageNum,Integer pageSize)throws Exception{
        int pageN = 0;
        int pageS=0;
        if(pageNum!=null){
            pageN=pageNum;
        }
        else{
            pageN=this.pageNum;
        }
        if(pageSize!=null){
            pageS=pageSize;
        }
        else{
            pageS=this.pageSize;
        }
        PageHelper.startPage(pageN,pageS);
        List<Map<String, Object>> listMap = slyzService.getByEntLicense();
        PageInfo pageInfo=new PageInfo(listMap);
        long total = pageInfo.getTotal();//总共多少条
        return resultService.result(ReturnStatus.SUCCESS,listMap,"成功",total);

    }

    /**
     *水路运政管理信息系统 SHIP_INFO  船舶信息
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/getByShipInfo")
    @ResponseBody
    public String getByShipInfo(Integer pageNum,Integer pageSize)throws Exception{
        int pageN = 0;
        int pageS=0;
        if(pageNum!=null){
            pageN=pageNum;
        }
        else{
            pageN=this.pageNum;
        }
        if(pageSize!=null){
            pageS=pageSize;
        }
        else{
            pageS=this.pageSize;
        }
        PageHelper.startPage(pageN,pageS);
        List<Map<String, Object>> listMap = slyzService.getByShipInfo();
        PageInfo pageInfo=new PageInfo(listMap);
        long total = pageInfo.getTotal();//总共多少条
        return resultService.result(ReturnStatus.SUCCESS,listMap,"成功",total);

    }

    /**
     *水路运政管理信息系统 SHIP_LICENSE  船舶营运证信息
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/getByShipLicense")
    @ResponseBody
    public String getByShipLicense(Integer pageNum,Integer pageSize)throws Exception{
        int pageN = 0;
        int pageS=0;
        if(pageNum!=null){
            pageN=pageNum;
        }
        else{
            pageN=this.pageNum;
        }
        if(pageSize!=null){
            pageS=pageSize;
        }
        else{
            pageS=this.pageSize;
        }
        PageHelper.startPage(pageN,pageS);
        List<Map<String, Object>> listMap = slyzService.getByShipLicense();
        PageInfo pageInfo=new PageInfo(listMap);
        long total = pageInfo.getTotal();//总共多少条
        return resultService.result(ReturnStatus.SUCCESS,listMap,"成功",total);

    }
}
